// src/utils/getWeekDates.ts

/**
 * 获取从今天开始的未来几天日期及星期几
 * @param days 要获取的天数（默认6天）
 * @returns 包含日期和星期几的数组
 */
export interface DateInfo {
  date: string;   // 格式: YYYY-MM-DD
  day: string;    // 星期几
  times:string;
  weekday: number | undefined; // 数字星期几 (0-6，0是周日)
}

export function getWeekDates(days: number = 6,time:string): DateInfo[] {
  const weekDays = ['周日', '周一', '周二', '周三', '周四', '周五', '周六'];
  const result: DateInfo[] = [];

  for (let i = 0; i <= days; i++) {
    const currentDate = new Date(time);
    currentDate.setDate(currentDate.getDate() + i);
    
    const year = currentDate.getFullYear();
    const month = String(currentDate.getMonth() + 1).padStart(2, '0');
    const day = String(currentDate.getDate()).padStart(2, '0');
    
    const weekday = currentDate.getDay(); // 0-6
    
    result.push({
      date: `${year}-${month}-${day}`,
      times:`${month}-${day}`,
      day: weekDays[weekday] ?? '',
      weekday
    });
  }

  return result;
}